<?php
require_once(__PHY_LIB.'/_smarty/Smarty.class.php');

class Tpl extends Smarty {
    function Tpl($sDir=false) {
        $this->Smarty();
        $this->template_dir = ($sDir ? $sDir : __PHY_WEB);
        $this->compile_dir  = __PHY_TMP.'/tpl_c/tpl';
        $this->left_delimiter  = '{-';
        $this->right_delimiter = '-}';
    }

	function assignConst() {
		foreach (get_defined_constants() as $k => $s) {
			if (0 === strpos($k, '__')) {
				$this->assign($k, $s);
			}
		}
    }

	function enableCache() {
		$this->cache_dir = __PHY_TMP.'/tpl_f/tpl';
		$this->caching = true;
	}
} /// end class Tpl.

class MktTpl extends Tpl {
    function MktTpl($sDir=false) {
        $this->Smarty();
        $this->template_dir = __PHY_WEB.$sDir;
        $this->compile_dir  = __PHY_TMP.'/tpl_c/mkttpl';
        $this->left_delimiter  = '<{';
        $this->right_delimiter = '}>';
    }

	function enableCache() {
		$this->cache_dir = __PHY_TMP.'/tpl_f/mkttpl';
		$this->caching = true;
	}

	function error($sTitle, $sDetail=false) {
		$this->assign('sTitle', $sTitle);
		$this->assign('sDetail', $sDetail);
		$this->display('error.tpl'); exit();
	}

	function redirect($sUrl) {
		$this->assign('sUrl', $sUrl);
		$this->display('redirect.tpl'); exit();
	}
} /// end class MktTpl.
?>
